<template>
  <div>
    <div class="title-container">
      <h3 class="title" style="color: black; font-weight: bold; text-align: center">个人信息</h3>
    </div>
    <div style="width: 70%; margin-top: 5%; margin: auto">
      <el-table :data="admin" border>
        <el-table-column label="用户名" prop="username"></el-table-column>
        <el-table-column label="邮箱" prop="email"></el-table-column>
        <el-table-column label="角色" prop="code"></el-table-column>
      </el-table>
    </div>
    <div style="margin-top: 20px; display: flex; justify-content: center; align-items: center">
      <div>
        <router-link to="/Center/changepwd">
          <el-button type="primary">修改密码</el-button>
        </router-link>
        <router-link to="/Center/email">
          <el-button type="success" style="margin-left: 100px">激活邮箱</el-button>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
import { throwStatement } from '@babel/types'
import { get } from 'js-cookie'
export default {
  name: 'admin',
  data() {
    return {
      admin: [
        {
          username: 11,
          email: '123@qq.com',
          // code: "lf123456",
        },
      ],
    }
  },
  methods: {
    get() {
      this.$store.dispatch('user/getInfo').then((response) => {
        console.log(response)
        console.log(response.username)
        this.admin[0].username = response.username
        this.admin[0].email = response.email
        // this.admin[0].code = response.id
        // return {
        //   admin: [{
        //     username: response.username,
        //     email: response.email,
        //     code: response.id
        //   }]
        // }
      })
    },
  },
  created() {
    this.get()
  },
}
</script>

<style scoped>
.message {
  width: 20em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>

